package com.itheima.reggie.dao;

import com.itheima.reggie.entity.Dish;
import com.itheima.reggie.entity.dto.DishDto;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface DishDao {

    @Select("select count(*) from dish where category_id=#{cateId}")
    Integer findCountByCateId(Long CateId);

    @Insert("insert into  dish values(null,#{name},#{categoryId},#{price},#{code},#{image},#{description},#{status},#{sort},#{createTime},#{updateTime},#{createUser},#{updateUser},0)")
    @Options(useGeneratedKeys = true, keyColumn = "id", keyProperty = "id")
    void save(DishDto dishDto);

    List<Dish> getByPage(String name);
    @Select("select * from dish where id=#{id}")
    Dish getById(Long id);

    void updateDish(DishDto dishDto);

    List<Dish> getByCategoryId(@Param("categoryId") Long categoryId, @Param("status") Integer status);
}
